package org.geekbang.projects.cs.search.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.geekbang.projects.cs.search.entity.PinnedQueryConfig;

/**
 * @description:
 * @author: Kaijun Chen
 * @date: 2023/3/17
 **/
public interface PinnedQueryConfigMapper extends BaseMapper<PinnedQueryConfig> {

    default PinnedQueryConfig findActivePinnedQueryConfigBySubjectWord(Integer businessType, String subjectWord) {
        LambdaQueryWrapper<PinnedQueryConfig> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PinnedQueryConfig::getSubjectWord, subjectWord);
        queryWrapper.eq(PinnedQueryConfig::getBusinessType, businessType);

        return selectOne(queryWrapper);
    }

}
